class Solution:
    def relativeSortArray(self, arr1: List[int], arr2: List[int]) -> List[int]:
        arr = [0 for _ in range(1001)]  
        ans = []  
        for i in range(len(arr1)):  
            arr[arr1[i]] += 1 
        for i in range(len(arr2)): 
            while arr[arr2[i]] > 0: 
                ans.append(arr2[i]) 
                arr[arr2[i]] -= 1 
        for i in range(len(arr)): 
            while arr[i] > 0:  
                ans.append(i)
                arr[i] -= 1
        return ans 
